<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/WEB-INF/views/head.jsp"/>
<script>
$(function() {
	$("#validForm").validate();
	$("input[name='username']").focus();
});
function confirmDelete() {
	return confirm("<s:message code='confirmDelete'/>");
}
</script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
	<h1><s:message code="user.management"/> - 头像修改</h1>
</div>
<c:set var="usernameExist"><s:message code="user.username.exist"/></c:set>
<div class="content">
	<div class="box box-primary">
		<form class="form-horizontal" id="validForm" action="update_avatar.do" method="post">
			<tags:search_params/>
			<f:hidden name="userId" value="${bean.id}"/>
			<f:hidden name="position" value="${position}"/>
			<input type="hidden" id="redirect" name="redirect" value="edit"/>
			<div class="box-header with-border">
				<div class="btn-toolbar">
					<div class="btn-group">
						<button class="btn btn-default" type="button" onclick="location.href='list.do?${searchstring}';"><s:message code="return"/></button>
					</div>
				</div>		
			</div>
            <div class="box-body">

                <div class="row">
                    <div class="row">
                        <div class="col-sm-8">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><em class="required">*</em>头像:</label>
                                <div class="col-sm-10">
                                    <script>
                                      function fn_smallImage(src) {
                                        Cms.scaleImg("img_smallImage", 200, 100, src);
                                      };
                                    </script>
                                    <div style="display:table;width:100%;">
                                        <div style="display:table-cell;vertical-align:middle;">
                                            <div class="input-group">
                                                <span class="input-group-addon">地址</span>
                                                <input type="text" id="smallImage" name="avatar"
                                                       value="${bean.avatar}"
                                                       onchange="fn_smallImage(this.value);" class="form-control required" readonly="true">
                                            </div>
                                            <div class="form-inline" style="margin-top:3px;">
                                                <%--<button class="btn btn-default" type="button" id="smallImageButton">选择--%>
                                                <%--</button>--%>
                                                <object id="SWFUpload_0" type="application/x-shockwave-flash"
                                                        data="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304"
                                                        width="54" height="34" class="swfupload">
                                                    <param name="wmode" value="transparent">
                                                    <param name="movie"
                                                           value="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304">
                                                    <param name="quality" value="high">
                                                    <param name="allowScriptAccess" value="always">
                                                    <param name="flashvars"
                                                           value="movieName=SWFUpload_0&amp;uploadURL=%2Fcmscp%2Fcore%2Fupload_image.do%3Bjsessionid%3DB7EED2164EABD024D9BFE3361803971D%3F_site%3D&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=file&amp;fileTypes=*.*&amp;fileTypesDescription=Images&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=&amp;buttonWidth=54&amp;buttonHeight=34&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-100&amp;buttonDisabled=false&amp;buttonCursor=-2">
                                                </object>
                                                <button class="btn btn-default" type="button">上传</button>
                                                <div style="display: none">
                                                    <button class="btn btn-default" type="button" id="smallImageSwfCancel"
                                                            onclick="smallImageSwfUpload.cancelQueue();" disabled="">取消
                                                    </button>
                                                </div>

                                            </div>

                                            <input type="hidden" id="t_smallImage" value="false">
                                            <input type="hidden" id="tw_smallImage" value="116">
                                            <input type="hidden" id="th_smallImage" value="77">
                                        </div>
                                        <div style="width:200px;display:table-cell;vertical-align:middle;text-align:center;">
                                            <img id="img_smallImage" <c:if test="${empty bean.avatar}">style="display:none;"</c:if>  src="${bean.avatar}" width="200px;" height="100px;">
                                        </div>
                                    </div>
                                    <div id="smallImageSwfProgress"></div>
                                    <script>
                                      var smallImageSwfUpload = Cms.swfUploadAvatarImage("smallImage","${bean.id}", {
                                        jsessionid: "B7EED2164EABD024D9BFE3361803971D",
                                        file_size_limit: "0",
                                        file_types: "*.*"
                                      });
                                      $(function () {
                                        Cms.f7.uploads("smallImage", "smallImage", {
                                          settings: {"title": "选择附件"},
                                          callbacks: {
                                            "ok": function (src) {
                                              fn_smallImage(src);
                                            }
                                          }
                                        });
                                      });
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>



            </div>



			<div class="box-footer">
        <button class="btn btn-primary" type="submit"><s:message code="save"/></button>
      	<button class="btn btn-default" type="submit" onclick="$('#redirect').val('list');"><s:message code="saveAndReturn"/></button>

		</form>
	</div>
</div>
</body>
</html>